#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
int w[20];
int f[N];
int m;
int main()
{
	cin >> m;
	int cnt = 0;
	for (int i = 1; i <= 20; i++) {
		if (i * i * i * i <= m)w[i] = i * i * i * i, cnt = i;
		else break;
	}
	memset(f, 0x3f, sizeof(f));
	f[0] = 0;
	for (int i = 1; i <= cnt; i++) {
		for (int j = w[i]; j <= m; j++) {
			f[j] = min(f[j], f[j - w[i]] + 1);
		}
	}
	cout << f[m] << endl;
	return 0;
}